 <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数组排序</title>
</head>
<body>
  
</body>
<script>
  var arr= [22,12,2,34,77,89,65,43,32,75];
  for(var i =0; i<arr.length;i++){
    var n=i;
    while(arr[n]>arr[n+1] && n >0){
      var temp = arr[n];
      arr[n]=arr[n+1];
      arr[n+1]=temp;
      n--;
    }
  }
</script>
</html> 